<?php

namespace app\admin\model\cms;

use think\Model;


class UserChatGroupsModel extends Model
{

    

    

    // 表名
    protected $table = 'user_chat_groups';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'datetime';
    //自动写入时间戳的格式
    protected $dateFormat = 'Y-m-d H:i:s';

    // 定义时间戳字段名
    protected $createTime = "created_at";
    protected $updateTime = "updated_at";
    protected $deleteTime = false;



    // 追加属性
    protected $append = [

    ];

    //一对一关联用户
    public function user()
    {
        return $this->hasOne("app\common\model\User", "id","user_id")->field('id,nickname,avatar,bio,email');
    }

    //一对多关联用户群组中间表
    public function userChatGroupUsers()
    {
        return $this->hasMany(UserChatGroupUsersModel::class, "chat_group_id","id");
    }
    

    







}
